home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
src890906.arc
/
NRDUMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-12
|
3KB
|
117 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "netrom.h"
#include "trace.h"
/* Display NET/ROM network and transport headers */
void
netrom_dump(bpp)
struct mbuf **bpp;
{
struct ax25_addr src,dest;
char x;
char tmp[16];
char thdr[5];
register i;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
/* See if it is a routing broadcast */
if(uchar(*(*bpp)->data) == 0xff) {
pullup(bpp,tmp,1); /* Signature */
pullup(bpp,tmp,ALEN);
tmp[ALEN] = '\0';
printf("NET/ROM Routing: %s\n",tmp);
for(i = 0;i < 11;i++) {
if (pullup(bpp,tmp,AXALEN) < AXALEN)
break;
memcpy(src.call,tmp,ALEN);
src.ssid = tmp[ALEN];
pax25(tmp,&src);
printf(" %12s",tmp);
pullup(bpp,tmp,ALEN);
tmp[ALEN] = '\0';
printf("%8s",tmp);
pullup(bpp,tmp,AXALEN);
memcpy(src.call,tmp, ALEN);
src.ssid = tmp[ALEN];
pax25(tmp,&src);
printf(" %12s", tmp);
pullup(bpp,tmp,1);
printf(" %3u\n", uchar(tmp[0]));
}
return;
}
/* Decode network layer */
pullup(bpp,tmp,AXALEN);
memcpy(src.call,tmp,ALEN);
src.ssid = tmp[ALEN];
pax25(tmp,&src);
printf("NET/ROM: %s",tmp);
pullup(bpp,tmp,AXALEN);
memcpy(dest.call,tmp,ALEN);
dest.ssid = tmp[ALEN];
pax25(tmp,&dest);
printf("->%s",tmp);
pullup(bpp,&x,1);
printf(" ttl %d\n",uchar(x));
/* Read first five bytes of "transport" header */
pullup(bpp,thdr,5);
switch(thdr[4] & 0xf){
case 0: /* network PID extension */
if (thdr[0] == NRPROTO_IP && thdr[1] == NRPROTO_IP) {
ip_dump(bpp,1) ;
return;
}
else
printf(" protocol family %x, proto %x",
uchar(thdr[0]), uchar(thdr[1])) ;
break ;
case 1: /* Connect request */
printf(" conn rqst: ckt %d/%d",uchar(thdr[0]),uchar(thdr[1]));
pullup(bpp,&x,1);
printf(" wnd %d",x);
pullup(bpp,(char *)&src,AXALEN);
pax25(tmp,&src);
printf(" %s",tmp);
pullup(bpp,(char *)&dest,AXALEN);
pax25(tmp,&dest);
printf("@%s",tmp);
break;
case 2: /* Connect acknowledgement */
printf(" conn ack: ur ckt %d/%d my ckt %d/%d",
uchar(thdr[0]), uchar(thdr[1]), uchar(thdr[2]),
uchar(thdr[3]));
pullup(bpp,&x,1);
printf(" wnd %d",x);
break;
case 3: /* Disconnect request */
printf(" disc: ckt %d/%d",uchar(thdr[0]),uchar(thdr[1]));
break;
case 4: /* Disconnect acknowledgement */
printf(" disc ack: ckt %d/%d",uchar(thdr[0]),uchar(thdr[1]));
break;
case 5: /* Information (data) */
printf(" info: ckt %d/%d",uchar(thdr[0]),uchar(thdr[1]));
printf(" txseq %d rxseq %d",uchar(thdr[2]), uchar(thdr[3]));
break;
case 6: /* Information acknowledgement */
printf(" info ack: ckt %d/%d",uchar(thdr[0]),uchar(thdr[1]));
printf(" txseq %d rxseq %d",uchar(thdr[2]), uchar(thdr[3]));
break;
default:
printf(" unknown transport type %d", thdr[4] & 0x0f) ;
break;
}
if(thdr[4] & 0x80)
printf(" CHOKE");
if(thdr[4] & 0x40)
printf(" NAK");
printf("\n");
}